<template>
  <div>
    <el-form-item label="组件默认值">
      <el-input v-model="value.defaultValue" placeholder="请输入组件默认值" />
    </el-form-item>
    <el-form-item label="字数限制">
      <el-switch v-model="value.showWordLimit"></el-switch>
    </el-form-item>
    <template v-if="value.showWordLimit">
      <!--      <el-form-item label="最小长度">-->
      <!--        <el-input v-model="value.minLength" :min="0"></el-input>-->
      <!--      </el-form-item>-->
      <el-form-item label="最大长度">
        <el-input v-model="value.maxLength" :min="0"></el-input>
      </el-form-item>
    </template>
    <el-form-item label="是否必填">
      <el-switch v-model="value.required"></el-switch>
    </el-form-item>
    <el-form-item label="必填校验提示" v-show="value.required">
      <el-input v-model="value.validateFailMessage" placeholder="必填校验提示" />
    </el-form-item>
    <el-form-item label="描述信息">
      <el-switch v-model="value.showDescription"></el-switch>
    </el-form-item>
    <el-form-item v-show="value.showDescription">
      <el-input type="textarea" :autosize="{ minRows: 4 }" v-model="value.description" placeholder="请输入描述信息" />
    </el-form-item>
    <el-form-item label="是否可清空">
      <el-switch v-model="value.clearable"></el-switch>
    </el-form-item>
  </div>
</template>

<script setup>
import { computed } from "vue";

const props = defineProps({
  modelValue: {
    type: Object,
    default: () => ({})
  }
});

const emit = defineEmits(["update:modelValue"]);
const value = computed({
  get() {
    return props.modelValue;
  },
  set(val) {
    emit("update:modelValue", val);
  }
});
</script>

<style scoped></style>
